package husc.se.ndung.soiphubaimobile;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

import husc.se.ndung.soiphubaimobile.Entity.ChiTietMay;
import husc.se.ndung.soiphubaimobile.Entity.CongDoan;

/**
 * Created by DungNguyen on 6/16/2015.
 */
public class AdapterCongDoan extends ArrayAdapter<CongDoan> {
    List<CongDoan> lsCongDoan;
    int resource;
    Activity context;

    public AdapterCongDoan(Activity context, int resource, List<CongDoan> objects) {
        super(context, resource, objects);
        this.context = context;
        this.resource = resource;
        this.lsCongDoan = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = context.getLayoutInflater().inflate(resource, null);
        TextView lbNameCongDoan = (TextView) convertView.findViewById(R.id.lbNameCongDoan);
        TextView lbThongTin = (TextView) convertView.findViewById(R.id.lbThongTinCongDoan);
        if (lbNameCongDoan!=null &&
                lbThongTin!=null)
        {
            lbNameCongDoan.setText(lsCongDoan.get(position).getTenCongDoan());
            lbThongTin.setText(lsCongDoan.get(position).getThongTinChung());
        }
        return convertView;
    }
}
